<%@page import="com.antexpress.pojo.Employee"%>
<%@page import="com.antexpress.common.Const"%>
<%@page import="com.antexpress.bean.Authentication"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Employee Home -- Ant Express</title>
        <link rel="shortcut icon" href="static/img/ant-logo.png">
        <link href="static/css/style.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/normalize.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/default.css" rel="stylesheet" type="text/css"/>
        <link href="static/dist/css/jquery.secretnav.css" rel="stylesheet" type="text/css"/>
        <link href="static/css/demo.css" rel="stylesheet" type="text/css"/>
        <link href="static/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
        <%
            if(!Authentication.isLogin(session)) {
                response.sendRedirect("index.jsp");
                return;
            }
            Employee user = (Employee)session.getAttribute(Const.CURRENT_USER);
        %>
        <div class="sn-outer-wrapper sn-moveleft modalview">
            <div class="sn-content-wrapper transform" style="cursor: default;">
                <div id="content" style="top: 0px;">
                    <jsp:include page="ui/header.jsp"/>
                    <div class="container-nav">
                        <div class="container">
                            <button class="open btn btn-default bt-open" title="Menu"><i class="fa fa-bars" aria-hidden="true"></i></button>
                            <a href="about.jsp" target="_blank" class='content-nav-bt' title="About author"><i class="fa fa-copyright" aria-hidden="true"></i></a>
                            <a href="tencent://Message/?Uin=82248481&amp;websiteName=q-zone.qq.com&amp;Menu=yes" class='content-nav-bt' title="Contact the administrator"><i class="fa fa-qq" aria-hidden="true"></i></a>
                            <a href="mailto:82248481@qq.com" class='content-nav-bt' title="Email the administrator"><i class="fa fa-envelope" aria-hidden="true"></i></a>
                        </div>
                    </div>
                    <div class="container" style="color:#000;padding-top: 20px;text-align: left;">
                        <div class="home-user-info-box">
                            <%
                                if(user.getGender().equals("m"))
                                    out.println("<img src='static/img/user_m.png' class='home-user'/>");
                                else
                                    out.println("<img src='static/img/user_f.png' class='home-user'/>");
                            %>
                            <br/>
                            <span style="font-weight: 500;"><%=user.getName()%></span>
                            <div style="margin-top:30px;">
                                <%=user.getTitle().getDepartment().getName()%><br/>
                                <%=user.getTitle().getName()%>
                            </div>
                        </div>
                        <div id="clock" style="display:inline-block; vertical-align: top; margin: 20px;">
                        </div>
                        <div style="display: inline-block;width: 700px;height: 200px;vertical-align: top;padding-top: 20px;">
                            <div class="home-msg-box">
                                <img src="static/img/work.png" class="msg-img" style="width: 60px;margin-top: 20px;"/><br/>
                                <span style="font-weight: 500">In-Service</span><br/>
                                <h4 id="service-msg">0</h4>
                            </div>
                            <div class="home-msg-box">
                                <img src="static/img/vacation.png" class="msg-img"/><br/>
                                <span style="font-weight: 500">Ask for leave</span><br/>
                                <h4 id="leaving-msg">0</h4>
                            </div>
                            <div class="home-msg-box">
                                <img src="static/img/bill_w.png" class="msg-img"/><br/>
                                <span style="font-weight: 500">Bill</span><br/>
                                <h4 id="bill-msg">0</h4>
                            </div>
                            <div class="home-msg-box">
                                <img src="static/img/car.png" class="msg-img"/><br/>
                                <span style="font-weight: 500">Delivering</span><br/>
                                <h4 id="delivering-msg">0</h4>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="sn-nav-wrapper">
                <nav id="nav" class="sn-nav left vertical">
                    <jsp:include page="ui/nav.jsp"/>
                </nav>
            </div>
        </div>
        <script src="static/js/modernizr.custom.25376.js" type="text/javascript"></script>
        <script src="static/js/jquery.js" type="text/javascript"></script>
        <script src="static/js/common-script.js" type="text/javascript"></script>
        <script src="static/dist/js/jquery.secretnav.js" type="text/javascript"></script>
        <script src="static/js/analogClock.js" type="text/javascript"></script>
        <script>
            $(function() {
                menu();
                AnalogClock("clock", { 
                    foreColor: "#fff",
                    width: 150,
                    bgColor: "#39a4c8"
                }); 
                initHomeMsg();
            });
            
            
            function initHomeMsg() {
                $.ajax({
                    url: "${pageContext.request.contextPath}/emps/home_emp.do",
                    type: "POST",
                    dataType: "json",
                    success: function(result) {
                        if(result.status === 1) {
                            $("#service-msg").text(result.data.service);
                            $("#leaving-msg").text(result.data.leaving);
                        }
                    }
                });
                $.ajax({
                    url: "${pageContext.request.contextPath}/express/getfinishedBillNum.do",
                    type: "POST",
                    dataType: "json",
                    success: function(result) {
                        if(result.status === 1) {
                            $("#bill-msg").text(result.data);
                        }
                    }
                });
                $.ajax({
                    url: "${pageContext.request.contextPath}/express/getNotFinishedBillNum.do",
                    type: "POST",
                    dataType: "json",
                    success: function(result) {
                        if(result.status === 1) {
                            $("#delivering-msg").text(result.data);
                        }
                    }
                });
            }
	</script>
    </body>
</html>
